package com.example.zou0614.controller;

import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@Service
public class time走起 {

    // 假设这是从前端接收到的成绩录入时间字符串
    private static final String INPUT_DATE_STRING = "2024-10-23"; // 例如：2023年10月23日

    public static boolean isScoreWithinCurrentMonth(String scoreInputDateString) {
        // 将字符串转换为LocalDate对象
        LocalDate scoreInputDate = LocalDate.parse(scoreInputDateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

        // 获取当前日期
        LocalDate currentDate = LocalDate.now();

        // 比较月份是否相同
        return scoreInputDate.getYear() == currentDate.getYear() && scoreInputDate.getMonthValue() == currentDate.getMonthValue();
    }

    public static void main(String[] args) {

        boolean isInCurrentMonth = time走起.isScoreWithinCurrentMonth(INPUT_DATE_STRING);
        System.out.println("Is score within current month? " + isInCurrentMonth);
    }
}
